<template>
		<view v-if="showFilter" style="display: flex;">
			<view   :style="{'width':searchWidth+'%'}">
				<uni-search-bar :bgColor="bgColor"  :radius="radius"   v-model="searchValue"  @focus="toSearch" @confirm="doSearch" @cancel="cancelSearch" cancelButton="none" :placeholder="placeHolder">
				</uni-search-bar>
			</view>
			<view class="filter" @click="filterClick"><text class="cell-icon yticon icon-filter" :class="shaiXuan"></text></view>
		</view>
		<view v-else style="width: 100%;display: inline-block;">
			<uni-search-bar :bgColor="bgColor"  :radius="radius"  v-model="searchValue"  @confirm="doSearch" @cancel="cancelSearch" cancelButton="auto" :placeholder="placeHolder">
			</uni-search-bar>
		</view>
</template>

<script>
	export default {
		props: {
			radius: {
				type: [Number, String],
				default: 20
			},
			bgColor:{
				type:String,
				default:'transparent'
			},
			searchWidth:{
				type:Number,
				default:90
			},
			placeHolder:{
				type:String,
				default:'请输入搜索关键词'
			},
			showFilter:{
				type:Boolean,
				default:true
			},
			shaiXuan:{
				type:String,
				default:''
			},
			
			
		},
		data() {
			return {
				searchValue:''
			}
		},
		created() {
		},
		methods: {
			filterClick(){
				this.$emit('filterClick');
				// console.log('点击了筛选',this.$refs);
				// this.$parent.$refs.popup.open('top')
			},
			doSearch(res){
				this.$emit('confirm1',res);
			},
			cancelSearch(){
				this.$emit('cancelSearch');
			},
			toSearch(){
				this.$emit('to_search');
			},
		
		}
	}
</script>

<style lang="scss" scoped>
	.filter{
		display: flex;
		align-items: center;
		
	}
</style>